package com.ptu.spzx.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ptu.spzx.model.entity.user.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {
    UserInfo selectByUsername(String username);

    void save(UserInfo userInfo);

    void setClassId(String stuId, String className);

    UserInfo getStu(String stuId);

    List<UserInfo> getStus(String className);

    @Update("update user_info set department=#{department},speciality=#{speciality} where stu_id=#{stuId}")
    Integer doAssign(Map<String, Object> params);

    @Select("SELECT stu_id FROM user_info WHERE class_name=#{className} AND is_deleted=0")
     List<String> getStuListByClass(@Param("className") String className);

    @Update("UPDATE user_info set class_name=null where class_name=#{className}")
    Integer setClaaNull(String className);

    @Select("SELECT * FROM user_info WHERE class_name=#{className} AND is_deleted=0")
    List<UserInfo> getStuListByClassName(@Param("className") String className);

    @Select("SELECT * FROM user_info WHERE stu_id=#{stuId} AND is_deleted=0")
    List<UserInfo> getStuListByStuId(String stuId);
}
